﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using EAS.Modularization;
using EAS.Data.Access;
using EAS.Data.ORM;
using EAS.Data.Linq;
using HR.Entities;
namespace HR.WinUI
{
    [Module("F5E96B51-9C57-4F43-A2C1-AF06942299B0", "人员字典", "人员名单显示")]
    public partial class EmployeeAddIn : UserControl
    {
        employee dict;
        [ModuleStart]
        public void startEX() 
        {
            this.LoadData();
            this.dataGridView1.Columns[7].ReadOnly = false;
            //this.dataGridView1.
        
        }
        public EmployeeAddIn()
        {
            InitializeComponent();
        }
         void LoadData()
        {
            DataEntityQuery<employee> query = new DataEntityQuery<employee>();
             var vlist=from  list in query
                       where list.InputCode.Contains(this.tbKey.Text.Trim (). ToUpper() )
                       select list;
             this.employeeBindingSource.DataSource = vlist;
            
        }
         public void selectAll(object sender, EventArgs e)
         {
             //this.Control_Enter(sender, e);
         }
         private void btnQuery_Click(object sender, EventArgs e)
         {
             this.LoadData();
         }

         private void textBoxAutoComplete1_InputComplete(object sender, EAS.Windows.UI.Controls.TextBoxInputEventAgrs e)
         {
             if (e.TextBox == this.textBox1)
             {
                 employee dict = this.textBox1.GetSelectedItem() as employee;
                 if (dict != null)
                 {
                     Filldict(dict);
                 }
             }       
         }
         //选中一项后绑定详细内容 
         private void Filldict(employee dict)
         {
             this.dict = dict;
             this.textBox1.Text = dict.Name;
             this.textBox2.Text = dict.Workshop;
             //txtContens.Text = dict.Spec;
             //txtInPrice.Text = dict.Price.ToString("0.00##");
             //this.txtBatch.Focus();
             //this.txtBatch.Select();
         }
    }
}
